#pragma once
#include "Rational.h"

class QuadraticField
{
private:
	Rational a, b;
	Integer d;
public:
	QuadraticField(): a(0), b(0), d(0) {};
	QuadraticField(const Rational &a): a(a), b(0), d(0) {};
	QuadraticField(const Rational &a, const Rational &b, const Integer &d, bool ok = false);
public:
	static const QuadraticField Zero;
	static const QuadraticField One;
	const Rational& Re(const QuadraticField &n) const;
	const Rational& Im(const QuadraticField &n) const;
	const Integer& Base(const QuadraticField &n) const;
	friend const Rational Trace(const QuadraticField &n);
	friend const Rational Norm(const QuadraticField &n);
	static const Integer Radix(const Integer &d);
	static const QuadraticField Unit(const Integer &d);
	const std::string str() const;
	friend std::ostream& operator<<(std::ostream &out, const QuadraticField &n);
	friend bool IsSameSystem(const QuadraticField &x, const QuadraticField &y);
	bool operator==(const QuadraticField &n) const;
	bool operator!=(const QuadraticField &n) const;
	const QuadraticField Conjugate(const QuadraticField &n) const;
	const QuadraticField operator-() const;
	friend const QuadraticField Inverse(const QuadraticField &n);
	const QuadraticField operator+(const QuadraticField &addend) const;
	QuadraticField& operator+=(const QuadraticField &addend);
	const QuadraticField operator-(const QuadraticField &subtrahend) const;
	QuadraticField& operator-=(const QuadraticField &subtrahend);
	const QuadraticField operator*(const QuadraticField &factor) const;
	QuadraticField& operator*=(const QuadraticField &factor);
	const QuadraticField operator/(const QuadraticField &divisor) const;
	QuadraticField& operator/=(const QuadraticField &divisor);
};

